package com.medusa.aps.business.modules.basic.controller;


import com.medusa.aps.business.modules.basic.model.input.WorkingCalendarPageParam;
import com.medusa.aps.business.modules.basic.model.output.CalendarModel;
import com.medusa.aps.business.modules.basic.model.output.CalendarWithHeaderModel;
import com.medusa.aps.business.modules.basic.mp.service.WorkingCalendarService;
import com.medusa.aps.business.common.model.resp.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 工作日历控制层
 *
 * @author yuxh
 * @since 2023-08-14 17:37:52
 */
@Tag(name = "工作日历控制层")
@RestController
@RequestMapping("/workingCalendar")
public class WorkingCalendarController {
    /**
     * 服务对象
     */
    @Resource
    private WorkingCalendarService workingCalendarService;

    /**
     * 分页查询工作日历数据
     *
     * @param query 分页查询参数
     * @return 所有数据
     */
    @Operation(description = "分页查询所有数据", method = "GET", summary = "分页查询所有数据")
    @GetMapping
    public Result<CalendarWithHeaderModel> calendarPage(WorkingCalendarPageParam query) {
        return Result.ok(
                workingCalendarService.calendarPage(query)
        );
    }

    /**
     * 编辑工作日历
     *
     * @param calendarModel 编辑工作日历参数
     */
    @PutMapping("/update")
    @Operation(description = "编辑工作日历")
    public Result<Void> updateCalendar(@RequestBody @Validated CalendarModel calendarModel) {
        workingCalendarService.updateCalendar(calendarModel);
        return Result.ok();
    }

}

